package com.qf.service.impl;

import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.pojo.User;
import com.qf.service.UserService;


/**
 * @author 29125
 * @version V1.0
 * @Project java2203
 * @Package com.qf.service.impl
 * @Description:
 * @Date 2022/5/27 13:31
 */
public class UserServiceImpl implements UserService {
    //用户注册
    @Override
    public boolean check(String username) {
        UserDao userDao=new UserDaoImpl();
        User user=userDao.findByUserName(username);
        if (user==null){
            return true;
        }else {
            return false;
        }
    }

    //用户登录
    @Override
    public User login(String username, String password) {
        //调用dao层方法
        UserDao userDao=new UserDaoImpl();
        User user = userDao.select(username,password);

//        //md5验证码密文，与数据库中密码的秘文user.getPassword()进行对比，一致则密码正确
//        String md5Pwd = MD5Utils.md5(password);
//        if (md5Pwd.equals(user.getPassword())){
//            return user;
//        }
        return user;
    }
}
